<?php


    require_once(MODEL_PATH.'/CMS/Base.php');
    //require_once(LIB_PATH.'/HTMLComponent.php');
    
    class Model_CMS_EmailActivation extends MODEL_CMS_Base{
    
        function __construct(){
        }
        
       function email_content_html($mid){
        $dbh_r = $this->db_connect('read');
        $email_status = db_select_one($dbh_r, 'select email_status from member_imore where id=?', $mid);
        
        // email already validated before. no need to send out
        if ($email_status==1){
        	return '';
        }
        $link = $this->link($mid);
        #閣下必須<a href="{#$email_activation_link#}">按此激活會員賬號</a>，方可於試用專區內申請試用。<BR>
        $content = "<a href=\"$link\">請立即按此以激活閣下之會員帳號！</a><BR><BR>";
        
        return $content;
      }
        
      private function link($mid){
         $dbh_r = $this->db_connect('read');
         list( $username, $email) = db_selectrow_array($dbh_r, 'select  username, email from member_imore where id=?', $mid);
         
         global $site_global_config;
         $global_url = $site_global_config['URL'];

         // Cliff: to be sync with www/member.php
         // pls put on config.
         $activationKey = "ImoreHK";

         $url = $global_url.'member.php'."?action=activation&membercode=".md5($activationKey.$mid.$username.$email)."&mid=".$mid;
        return $url;
       }
      
    }
    
    ?>